package main;

import dao.PriceDao;
import domain.price.Price;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		
		
		PriceDao pDao = new PriceDao();
		Price pObj = pDao.getPriceDetails(21);
		
		pDao.updatePriceDetails(22, pObj);
		
		
		
		/*ReproDao rDao = new ReproDao();
		SeasonalityRepro sea = new SeasonalityRepro();
		
		sea = rDao.getSeasonalityHeat(1);
		
		System.out.println("Pct_Adjustment: "+sea.getPctAdjustment());
		System.out.println("Seasonality: "+sea.getOverallSeasonality());
		for(int i=1; i<=Constants.SEA; i++){
			System.out.println("Monthly Seasonality (Month-"+i+"): "+sea.getMonthlySeasonality()[i]);
		}*/
		
		/*ReproDao rDao = new ReproDao();
		double abort[] = new double[Constants.MPREG+1];
		
		abort = rDao.getAbortRisk(1);
		
		for(int i=1; i<=Constants.MPREG; i++){
			System.out.println("Abort Month-"+i+"): "+abort[i]);
		}*/
		
		/*ReproDao rDao = new ReproDao();
		double concLact[] = new double[Constants.LACT+1];
		
		concLact = rDao.getConcRisk(1);
		
		for(int i=1; i<=Constants.LACT; i++){
			System.out.println("Conc Lact-"+i+"): "+concLact[i]);
		}*/
		
		/*ReproDao rDao = new ReproDao();
		double concMIM[] = new double[Constants.MIM+1];
		
		concMIM = rDao.getPctHeatMim(1);
		
		for(int i=3; i<=16; i++){
			System.out.println("Conc MIM-"+i+"): "+concMIM[i]);
		}
		
		ReproSvc svc = new ReproSvc();
		Repro repro = svc.getReproDetails(1); 
		
		for(int mim=3; mim<=16; mim++){
			for(int sea=1; sea<=12; sea++){
				System.out.printf("%2.4f\t",repro.getConceptionRate()[0][mim][sea]);
			}
			System.out.println("");
		}
		
		System.out.println("\n\n\n\n");
		for(int mim=3; mim<=16; mim++){
			for(int sea=1; sea<=12; sea++){
				System.out.printf("%2.4f\t",repro.getHeatDetectionRate()[mim][sea]);
			}
			System.out.println("");
		}*/
		//ArrayList<double> x = new ArrayList<double>();
		
		
		/*
		PriceSvc priceSvc = new PriceSvc();
		
		Price  p = priceSvc.getPriceDetails(1);
		
		
		for(int i=1; i <= 2 * Constants.SEA; i++){
			System.out.println(i+")\tBreed: "+p.getServe()[i]+"\tHeifer: "+p.getEnter()[i]+"\tHeifer Price: "+p.getP_heifer()[i]+"\tCull Price: "+p.getP_bodyweight()[i]+"\t\tMilk Price: "+p.getP_milk()[i]);
		}
		
		
		double a[][] = cullSvc.getProbIndCullTable(cullDao.getSeasonality(1), cullDao.getCullRiskMim(1));
				
		String s = "";
		for(int i=1;i<a.length;i++){
			for(int j=1; j<a[i].length; j++){
				//DecimalFormat df = new DecimalFormat("#.######");
				//s = s+"\t"+df.format(a[i][j]*100);
				s = s+"\t"+String.format("%.10g",a[i][j]);
			}
			//System.out.println(s);
			s = "";
		}
		
		
		
		
		MilkSvc svc = new MilkSvc();
		svc.getDefaultMilk();
		
		*/
		/*
		
		MiscDao dao = new MiscDao();
		Misc result = dao.getMiscDetails(1);
		
		System.out.println(result.getWritepol());
		System.out.println(result.getWriterpo());
		System.out.println(result.getStart_sea());
		System.out.println(result.getPolicy());
		System.out.println(result.getMaxmim());
		System.out.println(result.getCullmilk());
		System.out.println(result.getCullmargin());
		System.out.println(result.getInterest());
		System.out.println(result.getP_loss());
		System.out.println(result.getInvcullpct());
		System.out.println(result.getFunk());
		System.out.println(result.getP_calf());
		System.out.println(result.getP_fixed_labor());
		System.out.println(result.getP_fixed_other());
		System.out.println(result.getP_other_dry());
		System.out.println(result.getP_other_lact());
		System.out.println(result.getP_tmrdmdry());
		System.out.println(result.getP_tmrdmlac());
		System.out.println(result.getDmi_dry());
		System.out.println(result.getPctfat());
		System.out.println(result.getPa_cv());
		System.out.println(result.getMilkrepeat());
		System.out.println(result.getP_labor());
		System.out.println(result.getTimefresh());
		System.out.println(result.getTimelact());
		System.out.println(result.getTimedry());
		System.out.println(result.getVetcost()[1]);
		System.out.println(result.getVetcost()[2]);
		System.out.println(result.getVetcost()[3]);
		System.out.println(result.getVetcost()[4]);
		*/
				
		
		
		
		
		
		
		
		/*
		BWSvc svc = new BWSvc();
		
		BodyWeight bw = svc.getBodyWeightDetails(1, 1);
		
		double bo[][][] = bw.getBwOpen();
		double bp[][] = bw.getBwPreg();
		
		for (int i=1; i<=24 ; i++){
			System.out.println(bo[1][i][0] + "\t\t" + bo[2][i][0]);
		}
		System.out.println("\n\n-------------------------\n\n");
		for (int i=1; i<=9 ; i++){
			System.out.println(bp[1][i] + "\t\t" + bp[2][i]);
		}

		*/
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		/*long start, stop, time = 0;
		
		
		start = System.currentTimeMillis();
		System.out.println("Start Simulation : "+start);
		
		int fileNo = 3;
		Functions fun = new Functions();
		fun.startSimulation(fileNo);

		stop = System.currentTimeMillis();
		System.out.println("Stop Simulation : "+stop);
		time = stop - start;
		
		System.out.println("Simulation time: "+time/1000+" sec");
		System.out.println("\n\n\n\n\n");
		*/
		
		
		/*
		WriteFunction.writeFunction(36, bio, mkv, rpo, pol);
		*/
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		/*
		//WriteFunction.writePolFile(pol);
		System.out.println("\n\n\n\n\n");
		
		
		start = System.currentTimeMillis();
		System.out.println("Start Pol : "+start);
		polRpoDelDao.insertPolRecord(1, pol);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop Pol : "+stop);
		time = stop - start;
		
		System.out.println("Pol insert time: "+time/1000+" sec");
		
		
		start = System.currentTimeMillis();
		System.out.println("Start Rpo New : "+start);
		polRpoDelDao.insertRpoRecord(1, bio, rpo, ins);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop Rpo New : "+stop);
		time = stop - start;
		
		System.out.println("Rpo New insert time: "+time/1000+" sec");
		
		
		
		start = System.currentTimeMillis();
		System.out.println("Start Del : "+start);
		polRpoDelDao.insertDelRecord(1, del);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop Del : "+stop);
		time = stop - start;
		
		System.out.println("Del insert time: "+time/1000+" sec");
		
		*/
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		/*
		//PolRpoDelDao polRpoDelDao = new PolRpoDelDao();
		
		int fileNo = 1;
		int curr = 8;
		int lact = 1;
		int sea = 5;
		int conc = 16;
		
		
		
		
		start = System.currentTimeMillis();
		System.out.println("Start OpenRpo : "+start);
		double a[] = polRpoDelDao.getOpenRpo(fileNo, curr, lact, sea);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop OpenRpo : "+stop);
		time = stop - start;
		
		System.out.println("OpenRpo get time: "+time+" millisec");
		
		for (int i = 0; i < a.length; i++) {
			if(a[i]!=0){
				System.out.println("for i: "+i+"\t-- openCow: "+Utility.roundToZeroDecimal(a[i]));
			}
		}
		
		
		
		start = System.currentTimeMillis();
		System.out.println("Start PregRpo : "+start);
		double c[] = polRpoDelDao.getPregRpo(fileNo, curr, lact, conc, sea);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop PregRpo : "+stop);
		time = stop - start;
		
		System.out.println("PregRpo get time: "+time+" millisec");
		
		for (int i = 0; i < c.length; i++) {
			if(c[i]!=0){
				System.out.println("for i: "+i+"\t-- PregRpo: "+Utility.roundToZeroDecimal(c[i]));
			}
		}
		
		
		start = System.currentTimeMillis();
		System.out.println("Start PregValue : "+start);
		double d[] = polRpoDelDao.getPregValue(fileNo, curr, lact, conc, sea);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop PregValue : "+stop);
		time = stop - start;
		
		System.out.println("PregValue get time: "+time+" millisec");
		
		for (int i = 0; i < d.length; i++) {
			if(d[i]!=0){
				System.out.println("for i: "+i+"\t-- PregValue: "+Utility.roundToZeroDecimal(d[i]));
			}
		}
		
		

		start = System.currentTimeMillis();
		System.out.println("Start NewPregValue : "+start);
		double b[] = polRpoDelDao.getNewPregValue(fileNo, curr, lact, sea);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop NewPregValue : "+stop);
		time = stop - start;
		
		System.out.println("NewPregValue get time: "+time+" millisec");
		
		for (int i = 0; i < b.length; i++) {
			if(b[i]!=0){
				System.out.println("for i: "+i+"\t-- NewPregValue: "+Utility.roundToZeroDecimal(b[i]));
			}
		}
		
		
		start = System.currentTimeMillis();
		System.out.println("Start PregDelValue : "+start);
		double f[] = polRpoDelDao.getPregDelValue(fileNo, curr, lact, conc, sea);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop PregDelValue : "+stop);
		time = stop - start;
		
		System.out.println("PregDelValue get time: "+time+" millisec");
		
		for (int i = 0; i < f.length; i++) {
			if(f[i]!=0){
				System.out.println("for i: "+i+"\t-- PregDelValue: "+Utility.roundToZeroDecimal(f[i]));
			}
		}
		
		start = System.currentTimeMillis();
		System.out.println("Start OpenDelValue : "+start);
		double g[] = polRpoDelDao.getOpenDelValue(fileNo, curr, lact, conc, sea);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop OpenDelValue : "+stop);
		time = stop - start;
		
		System.out.println("OpenDelValue get time: "+time+" millisec");
		
		for (int i = 0; i < g.length; i++) {
			if(g[i]!=0){
				System.out.println("for i: "+i+"\t-- OpenDelValue: "+Utility.roundToZeroDecimal(g[i]));
			}
		}
		
		System.out.println("\nSuccesss .....");
		
		
		start = System.currentTimeMillis();
		System.out.println("Start InsValue : "+start);
		double e[] = polRpoDelDao.getInsValue(fileNo, curr, lact, sea);
		
		stop = System.currentTimeMillis();
		System.out.println("Stop InsValue : "+stop);
		time = stop - start;
		
		System.out.println("InsValue get time: "+time+" millisec");
		
		for (int i = 0; i < e.length; i++) {
			if(e[i]!=0){
				System.out.println("for i: "+i+"\t-- InsValue: "+Utility.roundToZeroDecimal(e[i]));
			}
		}
		*/
		

		
		
		
		
		
		
		
		
		
		
		
		
		
		/*BWDao bwDao = new BWDao();
		KorverFunction kFn = bwDao.getKorverFunction(1);
		bwDao.updateKorverFunction(2, kFn);*/
		
		//CullDao cullDao = new CullDao();
		/*double cullRiskLact[] = cullDao.getCullRiskLact(2);
		cullDao.updateCullRiskLact(2, cullRiskLact);*/
		/*double cullRiskMim[] = cullDao.getCullRiskMim(1);
		cullDao.updateCullRiskMim(2, cullRiskMim);*/
		/*SeasonalityCull sea = cullDao.getSeasonality(1);
		cullDao.updateSeasonality(2 , sea);*/
		
		/*LoginDao dao = new LoginDao();
		HashMap<String, String> result = new HashMap<String, String>();
		result = dao.getUidPwds();
		Iterator<String> itr = result.keySet().iterator();
		while(itr.hasNext()){
			String key = itr.next();
			System.out.println("Key : "+key+" Value: "+result.get(key));
		}
		
		//System.out.println("Register: "+dao.registerUser("new name", "useraaa", "passsdad"));
		
		dao.updatePassword("useraaa", "ppasssdad");*/
		
		
		/*
		MilkDao dao = new MilkDao();
		double [] sea = {0,1,2,3,4,5,6,7,8,9,10,11,12};
		
		
		SeasonalityMilk obj = new SeasonalityMilk();
		obj.setAbsAdjustment(dao.getSeasonality(1).getAbsAdjustment());
		obj.setOverallSeasonality(dao.getSeasonality(1).getOverallSeasonality());
		obj.setPctAdjustment(dao.getSeasonality(1).getPctAdjustment());
		obj.setMonthlySeasonality(dao.getSeasonality(1).getMonthlySeasonality());
		
		
		dao.updateSeasonality(2, obj);
		*/
		
		//FileDao dao = new FileDao();
		/*FileSvc svc = new FileSvc();
		ArrayList<FileDetails> files = svc.getAllFileList(3);
		
		for(int i=0; i<files.size(); i ++){
			System.out.println("UserId: "+files.get(i).getUserId()+"\tFileId: "+files.get(i).getFileNo()+"\tFile Name: "+files.get(i).getFileName()+"\tFile Desc: "+files.get(i).getFileDesc());
		}
		*/
		/*LoginDao login = new LoginDao();
		System.out.println("new java.util.Date().getTime(): "+new java.util.Date().getTime());
		java.sql.Time sqlTime = new Time(new java.util.Date().getTime());
		System.out.println("sqlTime.getDate(): "+sqlTime.toString());
		
		java.sql.Date sqlDate = new java.sql.Date(new java.util.Date().getTime());
		
		System.out.println("sqlDate: "+sqlDate.toString() +"   "+sqlDate.getTime());
		login.registerUser("Name2", "xay2", "asda");*/
		
		
		//FileDao fileDao = new FileDao();
		
		//int x = fileDao.createNewFile(1, "New File Create Test", "New File Create Test Description", 1);
		//System.out.println("x: "+x);
		
		//fileDao.deleteFile(3);
		//fileDao.deleteFile(4);
		//fileDao.deleteFile(5);
		
		
		
	}
	
	
	
	
	
	
	
	
	

}